#include "SandBoxMainMenu.h";

SandBoxMainMenu::SandBoxMainMenu(SdkTrayManager *mTrayMgr)
{
	this->mTrayMgr = mTrayMgr;

	versionCaption = mTrayMgr->createLabel(OgreBites::TL_TOP, "TVersionCaption", "", 2000);
	Ogre::StringVector holderItems;
	holder = mTrayMgr->createLongSelectMenu(OgreBites::TL_TOP, "THolder", "", 2000, 1, holderItems);

	windowCaption = mTrayMgr->createLabel(OgreBites::TL_CENTER, "TSandBoxMainMenuCaption", "..::SandBox - Main menu ::..", 350);

	mainMenuItems.push_back("");
	mainMenuItems.push_back("terrain_small.png");
	sceneMenu = mTrayMgr->createLongSelectMenu(OgreBites::TL_CENTER, "TMainMenu", "Select map:", 350, 200, 5, mainMenuItems);

	descriptionCaption = mTrayMgr->createLabel(OgreBites::TL_CENTER, "TSaveDescriptionCaption", "Description: ", 350);

	startButton = mTrayMgr->createButton(OgreBites::TL_CENTER,"TStartButton","Load selected map",200);
	exitButton = mTrayMgr->createButton(OgreBites::TL_BOTTOM,"TExitButton","Exit application",200);

	hide();
}

//------------------------------------------------------------------------------------------

SandBoxMainMenu::~SandBoxMainMenu(void)
{
}

//-------------------------------------------------------------------------------------------

void SandBoxMainMenu::injectMenuItems(Ogre::StringVector newMenuItems)
{
	sceneMenu->setItems(newMenuItems);
}

//-------------------------------------------------------------------------------------------

void SandBoxMainMenu::setDescriptionText(Ogre::String text)
{
	Ogre::String description = "Description: ";
	description.append(text);
	descriptionCaption->setCaption(description);
}

//-------------------------------------------------------------------------------------------

int SandBoxMainMenu::getSelectionIndex(void)
{
	return sceneMenu->getSelectionIndex();
}

//-------------------------------------------------------------------------------------------
void SandBoxMainMenu::show(void)
{
	mTrayMgr->hideFrameStats();
	mTrayMgr->showBackdrop("SdkTrays/Shade");
	mTrayMgr->moveWidgetToTray(versionCaption,OgreBites::TL_TOP);
	versionCaption->show();
	mTrayMgr->moveWidgetToTray(holder,OgreBites::TL_TOP);
	holder->show();
	mTrayMgr->moveWidgetToTray(windowCaption,OgreBites::TL_CENTER);
	windowCaption->show();
	mTrayMgr->moveWidgetToTray(sceneMenu,OgreBites::TL_CENTER);
	sceneMenu->show();
	mTrayMgr->moveWidgetToTray(descriptionCaption,OgreBites::TL_CENTER);
	descriptionCaption->show();
	mTrayMgr->moveWidgetToTray(startButton,OgreBites::TL_CENTER);
	startButton->show();
	mTrayMgr->moveWidgetToTray(exitButton,OgreBites::TL_BOTTOM);
	exitButton->show();
	mTrayMgr->showAll();
}

//-------------------------------------------------------------------------------------------

void SandBoxMainMenu::hide(void)
{
	mTrayMgr->hideBackdrop();
	mTrayMgr->removeWidgetFromTray(versionCaption);
	versionCaption->hide();
	mTrayMgr->removeWidgetFromTray(holder);
	holder->hide();
    mTrayMgr->removeWidgetFromTray(windowCaption);
	windowCaption->hide();
	mTrayMgr->removeWidgetFromTray(sceneMenu);
	sceneMenu->hide();
	mTrayMgr->removeWidgetFromTray(descriptionCaption);
	descriptionCaption->hide();
    mTrayMgr->removeWidgetFromTray(startButton);
	startButton->hide();
	mTrayMgr->removeWidgetFromTray(exitButton);
	exitButton->hide();

}